//
//  NewFeatureCell.m
//  OC-微博
//
//  Created by Apple on 15/11/10.
//  Copyright © 2015年 Apple. All rights reserved.
//

#import "NewFeatureCell.h"
@interface NewFeatureCell()
//图像
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UIButton *startBtn;
@end
@implementation NewFeatureCell
#pragma mark /*******************  懒加载  *******************/
-(UIImageView *)imageView {
    
    if (_imageView == nil) {
        _imageView = [UIImageView new];
        
    }
    return _imageView;
}
-(UIButton *)startBtn {
    if (_startBtn == nil) {
        _startBtn = [UIButton setBackImageName:@"new_feature_finish_button" title:@"开始体验" color:[UIColor whiteColor]];
    }
    return _startBtn;
}

#pragma mark /*******************  构造  *******************/
- (instancetype)initWithFrame:(CGRect)frame {

    if (self = [super initWithFrame:frame]) {
        [self setUI];
    }
    return self;
}
#pragma mark /*******************  添加子控件 *******************/
- (void)setUI {
    [self.contentView addSubview:self.imageView];
    [self.contentView addSubview:self.startBtn];
    //布局
    self.imageView.frame = self.bounds;
    [self.startBtn makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.bottom.equalTo(self).multipliedBy(0.7);
    }];
    [self.startBtn addTarget:self action:@selector(BtnClick) forControlEvents:UIControlEventTouchUpInside];
}
#pragma mark /*******************  监听方法  *******************/
- (void)BtnClick {
  //跳转视图
    [[NSNotificationCenter defaultCenter] postNotificationName:WBSwitchRootViewControllerNotification object:nil];
}
- (void)setImageIndex:(NSInteger)imageIndex {
    _imageIndex = imageIndex;
self.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"new_feature_%ld",_imageIndex+1]];
    self.startBtn.hidden = YES;
}
//动画
- (void)showButtonAnim {
    self.startBtn.hidden = NO;
    self.startBtn.transform = CGAffineTransformMakeScale(0, 0);
    self.startBtn.userInteractionEnabled = NO;
    [UIView animateWithDuration:1.6 delay:0 usingSpringWithDamping:0.8 initialSpringVelocity:10 options:0 animations:^{
        self.startBtn.transform = CGAffineTransformIdentity;
    } completion:^(BOOL finished) {
        
       self.startBtn.userInteractionEnabled = YES;
    }];

}
@end
